package com.huiqiao.lesson6.di;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

@Component
@PropertySource("config.properties")
public class ValueClass {

//    @Value("张三")
    @Value("${value.name}")
    private String name;

//    @Value("18")
    @Value("${value.age}")
    private int age;

    //spel复杂类型#{{'key':'value','key':'value'}子
//    @Value("#{{'语文': '90','数学': '100'}}")
    @Value("#{${score}}")
    private Map<String, Integer> score;

//    @Value("#{'唱歌,打球,写代码'}")
    @Value("#{'${hobbies}'.split(',')}")
    private List<String> hobbies;


    @Override
    public String toString() {
        return "ValueClass{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", score=" + score +
                ", hobbies=" + hobbies +
                '}';
    }
}
